<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>投保预览</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" />
<link rel="stylesheet" href="css/poshytip/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script src="js/common.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="js/poshytip/jquery.poshytip.js"></script>
<style type="text/css">
.setp{margin-bottom: 20px}
.mainMid {
    align-text:center;
    margin-right:40px;
    margin-left:40px;
    margin-top:20px;
    padding: 60px 98px;
    /* background: url(../images/mainCenterbg.png) repeat-y 0 0; */
    border: 2px solid #ececec;
    border-top: 3px solid #C1C1C1;''
}
.o-title {
    line-height: 26px;
    height: 26px;
    margin-bottom: 4px;
    overflow: hidden;
    font-size: 14px;
}
.o-tips {
    line-height: 20px;
    height: 20px;
}
.o-right-01 {
    float: right;
    padding-top: 14px;
    padding-bottom: 14px;
    padding-right: 10px;
    overflow: hidden;
}
.clr {
    display: block;
    overflow: hidden;
    clear: both;
    height: 0px;
    line-height: 0;
    font-size: 0px;
}
.insLineB{
    width: 100%;
    float: left;
    border-bottom:2px solid #ededed;
    margin:20px 0;
}
</style>
<script type="text/javascript">
$(function(){
    var tamount= '${facadeTempPolicy.amount}';
    var premNotax= '${facadeTempPolicy.facadeAppForms[0].premNotax}';
    var premVat= '${facadeTempPolicy.facadeAppForms[0].premVat}';
    tamount = fmoney(parseFloat(tamount));
    premNotax = fmoney(parseFloat(premNotax));
    premVat = fmoney(parseFloat(premVat));
    $("#amountId").html(tamount);
    $("#premNotax").html(premNotax);
    $("#premVat").html(premNotax);
    $("#amountId1").html(tamount);
    $("#premNotax1").html(premNotax);
    $("#premVat1").html(premNotax);
	init();
});
function init() {
    if('${pricelessType}'=="0"){
        stepConObj.stepContentFlag="1";//1非见费和2见费标识
        if('${facadeTempPolicy.status}'=='02'){
	        stepConObj.curStepIndex=4;//当前已完成索引位置
        }else{
            stepConObj.curStepIndex=3;//当前已完成索引位置
        }
        $('#payDiv').hide();
    }else{
        stepConObj.stepContentFlag="2";//1非见费和2见费标识
        if('${facadeTempPolicy.status}'=='11'||'${facadeTempPolicy.status}'=='13'){
            stepConObj.curStepIndex=3;//当前已完成索引位置
            $('#failDiv').hide();
        }else{
            stepConObj.curStepIndex=3;//当前已完成索引位置
            $('#payDiv').hide();
        }
    }
    stepControl(stepConObj);
}
//重新编辑
function editAgain1(cardNo,stagNo){
   window.location.href = "<%=path%>/activatedCard/group/add?cardNo="+cardNo+"&stagNo="+encodeURIComponent(stagNo)+"&editFlag=edit";
}
function showErrorInfo(obj){
    $.dialog({
        type: "error",
        content: obj,
        onOk: function() {
        }
    });
}
//支付
function pay(stagNo,pricelessType){
     stepConObj.curStepIndex=4;//当前已完成索引位置
     stepControl(stepConObj);
     var effdates=$(" .effdate");
     var beginTime="";
     //取出最小的日期
     for(var i=0;i<effdates.length;i++){
         
         if(i>0){
             if(compareTo(beginTime,effdates[i].value)){
                 beginTime=effdates[i].value;
             }
         }else{
             beginTime=effdates[i].value;
         }
         
     }
     var now = new Date;
     now.setMinutes (now.getMinutes () + 10);
     var nowDate=now.getFullYear()+"-"+(((now.getMonth()+1)<10)?("0"+(now.getMonth()+1)):(now.getMonth()+1))+"-"+comple_Zero(now.getDate())+" "+comple_Zero(now.getHours())+":"+comple_Zero(now.getMinutes())+":00";
     
     if(compareTo(nowDate,beginTime)){
         $.dialog2({
             width: 400,
             top:40,
             height:120,
             title: "支付提示",
             ok:"确定",
             cancel:"取消",
             content: "<div style='margin:20px'>当前时间已晚于规定支付时间，请重新投保！</div>",
             onClose:function(){
                 
             },
             onCancel:function(){
                 
             },
             onOk: function() {
                 
             }
         });
         return;
     }
     $.dialog2({
         width: 400,
         top:40,
         title: "支付提示",
         ok:"支付遇到问题",
         cancel:"支付完成",
         content: "<div style='margin:20px'>支付完成前，请不要关闭此支付验证窗口。为了您的保单及时生效，请在今天23:59之前完成支付，支付完成点击以下按钮继续操作。</div>",
         onClose:function(){
         },
         onCancel:function(){
             window.location.href = "<%=path%>/pay/resultNlife?stagNo="+encodeURIComponent(stagNo)+"&pricelessType="+pricelessType+"&type=2";
         },
         onOk: function() {
             window.location.href = "<%=path%>/pay/resultNlife?stagNo="+encodeURIComponent(stagNo)+"&pricelessType="+pricelessType+"&type=2";
         }
     });
    <%-- window.open("<%=path%>/pay/newpayment?stagNo="+encodeURIComponent(stagNo))+"&type=2"; --%>
    <%--对接新支付平台 20190328 helina--%>
    window.open("<%=path%>/pay/newpaymentmethod?stagNo="+encodeURIComponent(stagNo))+"&type=2";
}
function comple_Zero(s){
    return (((s+1)<10)?("0"+(s)):(s));
}
function compareTo(beginTime,endTime){
    var beginTimes = beginTime.substring(0,10).split('-');  
    var endTimes   =  endTime.substring(0,10).split('-');  
      
    beginTime = beginTimes[1]+'-'+beginTimes[2]+'-'+beginTimes[0]+' '+beginTime.substring(10,19);  
    endTime    = endTimes[1]+'-'+endTimes[2]+'-'+endTimes[0]+' '+endTime.substring(10,19);   
    var a =(Date.parse(endTime)-Date.parse(beginTime))/3600/1000;
    if(a<0){
        return true;
    }else if (a>0){
        return false;
    }else if (a==0){  
        return true;
    }  
 }
</script>
</head>
<body>
    <div class="current">
        <table class="current_table_1">
            <tbody>
                <tr class="f2">
                    <td><img src="./images/current_1.jpg"></td>
                    <td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                        <span style="color: #136bab;">激活卡管理 <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>激活卡激活
                            <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>核保
                    </span></td>
                    <td><img src="./images/current_3.jpg"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="mainMid">
        <div class="setp"><jsp:include page="../include/stepScroll.jsp"/></div>
        <div id="failDiv">
           <h3 class="o-title">
            <span style="color: #F45821;margin-left:50px">核保失败,请编辑后重试！</span>
           </h3>
            <div class="o-right-01">
                <c:if test="${facadeTempPolicy.status!='01'}">
                <div class="o-price">
                    <em>含税保费：</em><strong><span style="color: #F45821;" id="amountId1"></span><em>&nbsp;&nbsp;元</em></strong>
                    <em>&nbsp;不含税保费：</em><strong><span id="premNotax1"></span><em>元&nbsp;&nbsp;</em></strong>
                    <em>&nbsp;增值税额：</em><strong><span id="premVat1"></span><em>元</em></strong>
                </div>
               </c:if>
            </div>
            <div class="insLineB">
            </div>
            <div style="magin_top:20px">
            <table id="policyInfo" align="center">
                <thead>
                    <tr>
                        <th width="300px">状态</th>
                        <th width="300px">投保单号</th>
                        <th width="300px">起保日期</th>
                        <th width="100px">操作</th>
                    </tr>
                </thead>
                <tbody>
                  <c:forEach var="facadeAppForm" items="${facadeTempPolicy.facadeAppForms}">
                    <tr>
                        <td align="center">
                            <span style="color: #F45821;">失败<a  href="javascript:;" onclick="showErrorInfo('${facadeAppForm.errInfo}')"  title="${facadeAppForm.errInfo}" >[查看详情]</a></span>
                        </td>
                        <td align="center">
                            ${facadeAppForm.appNo}
                        </td>
                        <td align="center">
                            ${facadeAppForm.stringEffDate}<input class='effdate' type="hidden" value="${facadeAppForm.stringEffDate}">
                        </td>
                        <td align="center">
                            <a href="javascript:editAgain1('${cardNo}','${stag_No}');">[编  辑]</a>
                        </td>
                    </tr>
                  </c:forEach>
                </tbody>
            </table>
            </div>
             <div class="insLineB">
             </div>
	        <div align="center" style="magin_top:20px">
	           <input class="input_button_2" name="" type="button" onclick="window.history.back();return false;" id="back" value="返  回">&nbsp;&nbsp;
            </div>
        </div>
        
        <div id="payDiv">
            <div class="o-right-01">
                <c:if test="${facadeTempPolicy.status!='01'}">
                <div class="o-price">
                    <em>含税保费：</em><strong><span style="color: #F45821;" id="amountId"></span><em>&nbsp;&nbsp;元</em></strong>
                    <em>&nbsp;不含税保费：</em><strong><span id="premNotax"></span><em>元&nbsp;&nbsp;</em></strong>
                    <em>&nbsp;增值税额：</em><strong><span id="premVat"></span><em>元</em></strong>
                </div>
               </c:if>
            </div>
           <h3 class="o-title" style="color: #F45821;">
            <span style="color: #F45821;">核保成功,请支付！</span>
           </h3>
            <p class="o-tips"> 请您在起保日期10分钟前完成支付，否则保单将作废！</p>
            
            <div class="insLineB">
            </div>
            <div style="magin_top:20px">
            <table id="policyInfo" align="center">
                <thead>
                    <tr height="26px">
                        <th width="300px">状态</th>
                        <th width="300px">投保单号</th>
                        <th width="300px">起保日期</th>
                        <th width="100px">操作</th>
                    </tr>
                </thead>
                <tbody>
                  <c:forEach var="facadeAppForm" items="${facadeTempPolicy.facadeAppForms}">
                    <tr height="26px">
                        <td align="center">
                            <c:choose>
                               <c:when test="${facadeAppForm.resultCode=='00'}">
                                                                                                  成功
                               </c:when>
                               <c:otherwise>
                                    <span style="color: #F45821;">失败<a  href="javascript:;" onclick="showErrorInfo('${facadeAppForm.errInfo}')"  title="${facadeAppForm.errInfo}" >[查看详情]</a></span>
                               </c:otherwise>
                            </c:choose> 
                        </td>
                        <td align="center">
                            ${facadeAppForm.appNo}
                        </td>
                        <td align="center">
                            ${facadeAppForm.stringEffDate}<input class='effdate' type="hidden" value="${facadeAppForm.stringEffDate}">
                        </td>
                        <td align="center">
                            <c:choose>
                                <c:when test="${facadeAppForm.resultCode!='00'}">
                                     <a href="javascript:editAgain1('${cardNo}','${stag_No}');">[编  辑]</a>
                                </c:when>
                                <c:otherwise>
                                     <c:choose>
                                         <c:when test="${pricelessType=='0'}">
                                                                                                                                 出单成功
                                         </c:when>
                                         <c:otherwise>
                                                                                                                                 待支付
                                         </c:otherwise>
                                     </c:choose>
                                </c:otherwise>  
                             </c:choose>
                        </td>
                    </tr>
                  </c:forEach>
                </tbody>
            </table>
        </div>
        <div class="insLineB">
        </div>
        <div id="payButton" align="center" style="margin-top:20px">
           <input class="input_button_2" name="" type="button" onclick="pay('${stag_No}','${pricelessType}')" value="确认支付">
        </div>
        </div>
        <br>
    </div>
</body>
</html>